<?php
/**
 * Created by PhpStorm.
 * User: sunshubo
 * Date: 2017/9/19
 * Time: 15:25
 */
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"/>
    <link rel="shortcut icon Bookmark" href="/favicon.ico">
    <link rel="stylesheet" type="text/css" href="/static/css/base.css?t=1505204250563"/>
    <link rel="stylesheet" type="text/css" href="/static/css/dpl.css?t=1505204250563"/>
    <link rel="stylesheet" type="text/css" href="https://wx-static.drip.im/css/shop/form/preview.css?t=1505204250563"/>
    <link rel="stylesheet" type="text/css" href="/static/css/index.css"/>
    <!--    <link rel="stylesheet" type="text/css" href="https://wx-static.drip.im/css/shop/form/activity.css?t=1505204250563"/>-->
    <!--    <link rel="stylesheet" type="text/css"          href="https://wx-static.drip.im/css/fonts/form/iconfont.css?t=1505204250563"/>-->
    <!--    <meta http-equiv="Content-Security-Policy"-->
    <!--          content="script-src 'self' 'nonce-99b4ecf93d7b2b23' 'unsafe-inline' 'unsafe-eval' https: *.qq.com api.map.baidu.com wx-static.drip.im eco-api.meiqia.com wxs-b.drip.im hm.baidu.com;object-src *.qq.com *.youku.com;frame-src *.qq.com *.youku.com weixinping: weixin:">-->
    <!--<script src='js/lrz.all.bundle.js?t=1505204250563'></script>-->
    <!--<script src="js/sea.js?t=1505204250563"></script>-->
    <!--<script src="https://wx-static.drip.im/js/dist/shop/form/validate.js?92324,860188516"></script>-->
    <script src="/static/js/jquery.js"></script>
    <script src="//cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
    <script src="//cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"></script>
    <script src="/static/js/qrcode.js"></script>
    <title> 文思学堂 - 学籍管理系统</title>
</head>
<body>
<!—[if lte IE 10]>
<script nonce="99b4ecf93d7b2b23">document.createElement('header');</script>
<![endif]—>
<div class="screen">
    <div class="widget hidden">
        <a onclick="setWidget();">
            <span>+</span>
        </a>
    </div>
    <table id="field_100" data-field-id="100" class="widget_table hidden">
        <tr>
            <div class="dui-mask hidden"></div>
        </tr>
        <form method="get" action="#">
            <tr>
                <td>
                    <button type="submit" formaction="add/teacher">添加老师</button>
                </td>
            </tr>
            <tr style="height: 40px;" align="center">
                <td>
                    <button type="submit" formaction="add/student">添加学生</button>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <button type="submit" formaction="add/admin">添加管理员</button>
                </td>
            </tr>
        </form>
    </table>
    <div id="field_101" data-field-id="101" class='ui-form style_9'>
        <div class="ui-title"> 文思学堂 - 未来教育专家
            <span style="float: right;"><a id="exit" onclick="exit();" class="hidden">退出</a></span>
        </div>
        <div class="ui-content form-fields">
            <div class="form-desc">
                <table class="group">
                    <tr align="center">
                        <td>
                            <image class='img' src="/static/img/logo_200_200.png" style="width: 80%"></image>
                        </td>
                    </tr>
                    <tr id="button" align="center" class="hidden">
                        <td>
                            <form action="input" method="get">
                                <button id="field_101" data-field-id="101" class="message " type="submit"
                                        formaction="input" hidden>录入学生信息
                                </button>
                                <button id="field_102" data-field-id="102" class="message " type="submit"
                                        formaction="mark" hidden>录入作业信息
                                </button>
                                <button id="field_103" data-field-id="103" class="message " type="submit"
                                        formaction="aoshu" hidden>录入奥数信息
                                </button>
                                <button id="field_104" data-field-id="104" class="message " type="submit"
                                        formaction="shufa" hidden>录入书法信息
                                </button>
                                <button id="field_105" data-field-id="105" class="message " type="submit"
                                        formaction="zuowen" hidden>录入作文信息
                                </button>
                                <button id="field_106" data-field-id="106" class="message " type="submit"
                                        formaction="dashboard" hidden>查看学生画像
                                </button>
                            </form>
                        </td>
                    </tr>
                    <tr id="login_tr">
                        <td>
                            <div class="ui-field" id="field_105">
                                <label class="field-label"> 用户名 <span class="required">*</span>
                                    <span id="name_err" class="tips"></span>
                                </label>
                                <div class="field-content">
                                    <input id="name" type="text" class="ui-input" placeholder="如果您是家长,请填写手机号码"
                                           name="name"/>
                                </div>
                            </div>
                            <div class="ui-field" id="field_105">
                                <label class="field-label"> 密 码 <span class="required">*</span>
                                    <span id="name_err" class="tips"></span>
                                </label>
                                <div class="field-content">
                                    <input id="pass" type="password" class="ui-input" placeholder="请填写登录密码"
                                           name="pass"/>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr id="login_button">
                        <td>
                            <button class="message" style="display:block;">登录学堂</button>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <footer class="drip-footer">
            <p> © <a href="#">文思学堂</a> 最终解析权 </p>
        </footer>
        <div class="hidden" data-userinfo="" id="userinfo"></div>
        <div id="dui-alert-tpl" type="text/template" class="hidden">
            <div class="dui-dialog-box">
                <div class="dui-mask"></div>
                <div class="dui-dialog">
                    <div class="dialog-hd">提示</div>
                    <div id="msg" class="dialog-bd"></div>
                    <div class="dialog-ft">
                        <a>确定</a>
                    </div>
                </div>
            </div>
        </div>
        <div id="loading" class="submit-loading hidden">
            <div class="wrap">
                <div class="circle"></div>
                <p>提交中</p></div>
        </div>
        <div class="submit-loading">
            <div class="wrap">
                <div class="circle"></div>
                <p>加载中</p></div>
        </div>
    </div>
</div>
</body>
<script nonce="99b4ecf93d7b2b23">
    var hidden = false;
    $(function () {
        $(".submit-loading").addClass("hidden");
        flogin({'t': readCooken()});
    });
    $(document).click(function () {
        $("#dui-alert-tpl").addClass("hidden");
    });
    $("button").click(function () {
        const data = {
            'name': $("#name").val(),
            'pass': $("#pass").val()
        };
        $.post('/login', data, function (data, status) {
            sk(data);
        })
    });
    $(".dui-mask").click(function () {
        $(".dui-mask").fadeOut();
        $(".widget_table").fadeOut();
        hidden = !hidden;
    });

    function sk(data) {
        data = strToJson(data);
        console.log(data);
        if (data.result === 0) {
            $("#login_tr").addClass("hidden");
            $("#login_button").addClass("hidden");
            $("#button").removeClass("hidden");
            $("#exit").removeClass("hidden");
        }
        if (data['msg'] !== '') {
            $("#dui-alert-tpl").removeClass("hidden");
            $("#msg").html(data['msg']);
            $(".dui-alert-tpl").fadeIn(200);
        }
        switch (data['p']) {
            case "1":
                $(".widget").removeClass("hidden");
                $("#field_101").css('display', 'block');
                $("#field_102").css('display', 'block');
                $("#field_103").css('display', 'block');
                $("#field_104").css('display', 'block');
                $("#field_105").css('display', 'block');
                $("#field_106").css('display', 'block');
                break;
            case "2":
                $("#field_102").css('display', 'block');
                break;
            case "3":
                $("#field_103").css('display', 'block');
                break;
            case "4":
                $("#field_104").css('display', 'block');
                break;
            case "5":
                $("#field_105").css('display', 'block');
                break;
            case "6":
                $("#field_106").css('display', 'block');
                break;
        }
    }

    function strToJson(str) {
        return eval('(' + str + ')');
    }

    function exit() {
        $.get('/logout', function (data, status) {
            window.location.href = 'http://www.zoier.cn';
        })
    }

    function readCooken() {
        return ($.cookie('_wsxt'));
    }

    function flogin(data) {
        $.post('/auth', data, function (data, status) {
            sk(data);
        });
    }

    function setWidget() {
//        hidden ? setTimeout("$(\".widget_table\").addClass(\"hidden\")", 300) : $(".widget_table").removeClass("hidden");
//        hidden ? setTimeout("$(\".dui-mask\").addClass(\"hidden\")", 300) : $(".dui-mask").removeClass("hidden");
//        hidden ? $("table").animate({right: '0px'}) : $("table").animate({right: '50px'});
//        hidden = !hidden;
        hidden ? $(".widget_table").fadeIn() : $(".widget_table").fadeOut();
        $(".dui-mask").fadeIn();
        $(".widget_table").fadeIn();
        hidden = !hidden;
    }
</script>
</html>